﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Web.User;
using PowerCreator.LMS.Web.Task;
using PowerCreator.LMS.Task.Entity;
using PowerCreator.LMS.ViewQuery;
using PowerCreator.LMS.Common.Utils;

public partial class Theme_3_AddTaskComment : PowerCreator.LMS.Web.Base.BasePage
{
    TaskManag objTaskManag = new TaskManag();
    TaskCommentManag objTaskCommentManag = new TaskCommentManag();
    string rid = "0";
    string cid = "";
    int playtime = 0;
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Request.Params["TaskID"] != null && Request.Params["TaskID"].Trim() != "")
        {
            int TaskID = int.Parse(Request.Params["TaskID"].ToString());
            ViewState["TaskID"] = TaskID;

        }
        if (Request.Params["TaskClassID"] != null && Request.Params["TaskClassID"].Trim() != "")
        {
            int TaskClassID = int.Parse(Request.Params["TaskClassID"].ToString());
            ViewState["TaskClassID"] = TaskClassID;

        }
        if (Request.Params["TaskUserID"] != null && Request.Params["TaskUserID"].Trim() != "")
        {
            int TaskUserID = int.Parse(Request.Params["TaskUserID"].ToString());
            ViewState["TaskUserID"] = TaskUserID;

        }
        if (Request.Params["ResourceID"] != null)
        {
            rid = Request.QueryString["ResourceID"].ToString();
            ViewState["ResourceID"] = rid;
        }
        if (Request.Params["ContentID"] != null)
        {
            cid = Request.QueryString["ContentID"].ToString();
            ViewState["ContentID"] = cid;
        }

        if (Request.Params["position"] != null)
        {
            string Playtime = Request.QueryString["position"].ToString();
            ViewState["position"] = Playtime;
        }
        string Content = Request.QueryString["filter"].ToString();
        ViewState["Content"] = Content;
        Add();
    }

    void Add()
    {
        TaskComment objTaskComment = new TaskComment();

        int UserID = GetLoginEntity.UserID;
        objTaskComment.TaskCtTaskID = int.Parse(ViewState["TaskID"].ToString());
        objTaskComment.TaskCtTaskClassID = int.Parse(ViewState["TaskClassID"].ToString());
        objTaskComment.TaskCtUserID = int.Parse(ViewState["TaskUserID"].ToString());
        objTaskComment.TaskCtTitile = "";
        objTaskComment.TaskCtContent = ViewState["Content"].ToString();

        objTaskComment.FKTaskCtResourceID = int.Parse(rid);

        objTaskComment.FkTaskCtTargetID = 0;


        objTaskComment.FKTaskCtResourceGuid = cid;

        
        if (ViewState["position"] != null)
            playtime = int.Parse(ViewState["position"].ToString());
      
        objTaskComment.TaskCtVideoTime = playtime;
        objTaskComment.TaskCtScore = 0;
        objTaskComment.TaskCtUrl = "";
        objTaskComment.TaskCtRangeType = 0;
        objTaskComment.TaskCtType = 0;
        objTaskComment.TaskCtCreateTime = DateTime.Now; ;
        objTaskComment.FKTaskCtCreateID = UserID;

       

        if (objTaskCommentManag.AddNew(objTaskComment))
        {
            Response.Write("1");
        }
        else
        {
            Response.Write("0");
        }
        Response.End();
    }
}
